package fr.eisti.icc.data;

import fr.eisti.icc.zk.LoginController;
import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author clion
 */
@Entity
@Table(name = "BIBLIOTHEQUE")
@XmlRootElement
public class Bibliotheque implements Serializable {

    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = false)
    @LazyCollection(LazyCollectionOption.FALSE)
    private List<Reservation> reservations;
    @Id
    @Column(name = "id")
    private int id;
    //Liste des utilisateurs de la bibliotheque
    @LazyCollection(LazyCollectionOption.FALSE)
    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true)
    private List<Emprunteur> clients;
    //Liste des documents de la bibliotheque
    @OneToMany(cascade = {CascadeType.ALL}, orphanRemoval = true)
    private List<Document> documents;
    private static Bibliotheque instance = null;
    @Column(name = "passProf")
    private String passProf;
    @Column(name = "passAdmin")
    private String passAdmin;

    //////////////////////////////////CONSTRUCTEURS//////////////////////////////////
    public Bibliotheque() {
    }

    public Bibliotheque(int id) {
        this.id = id;
        passAdmin = LoginController.crypteMotDePasse("ICC3822");
        passProf = LoginController.crypteMotDePasse("auBoulot");
    }

    //////////////////////////////////GETTERS+SETTERS//////////////////////////////////
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @XmlTransient
    public List<Emprunteur> getClients() {
        return clients;
    }

    public void setClients(List<Emprunteur> clients) {
        this.clients = clients;
    }

    @XmlTransient
    public List<Document> getDocuments() {
        return documents;
    }

    public void setDocuments(List<Document> documents) {
        this.documents = documents;
    }

    //////////////////////////////////fONCTIONS//////////////////////////////////
    @XmlTransient
    public List<Reservation> getReservations() {
        return reservations;
    }

    public void setReservations(List<Reservation> reservations) {
        this.reservations = reservations;
    }

    public String getPassProf() {
        return passProf;
    }

    public void setPassProf(String passProf) {
        this.passProf = passProf;
    }

    public String getPassAdmin() {
        return passAdmin;
    }

    public void setPassAdmin(String passAdmin) {
        this.passAdmin = passAdmin;
    }
}